//
//  ContactsTableViewController.m
//  WhatsChat
//
//  Created by lanou3g on 16/3/23.
//  Copyright © 2016年 tanchen. All rights reserved.
//

#import "ContactsTableViewController.h"
#import "ContactsTableViewCell.h"
#import "PersonInfoViewController.h"
#import "RootTableView.h"

@interface ContactsTableView : RootTableView

@end

@implementation ContactsTableView

@end

@interface ContactsTableViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,strong) ContactsTableView *tabelView;

@end

@implementation ContactsTableViewController

- (void)loadView{
    self.tabelView = [[ContactsTableView alloc]initWithFrame:[UIScreen mainScreen].bounds];
    self.tabelView.backgroundColor = [UIColor blackColor];
    self.view = self.tabelView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    //注册
    [self.tabelView.rootTableView registerClass:[ContactsTableViewCell class] forCellReuseIdentifier:@"contactscell"];
    self.tabelView.rootTableView.delegate = self;
    self.tabelView.rootTableView.dataSource = self;
    
    // 设置导航栏所有按钮标题和按钮图像的颜色
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    //导航栏颜色
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0.2 green:0.72 blue:0.46 alpha:1];
    //设置透明度
    self.navigationController.navigationBar.translucent = YES;
    //导航栏标题
    self.navigationItem.title = @"通讯录";
    //设置字体
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20],NSForegroundColorAttributeName:[UIColor whiteColor]}];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    NSString *indentifier = @"contacts";
    ContactsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indentifier];
    if (!cell) {
        cell = [[ContactsTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indentifier];
    }
    //cell点击不变色
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    return 60.0f;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    PersonInfoViewController *personInfoVC = [[PersonInfoViewController alloc]init];
    [self.navigationController pushViewController:personInfoVC animated:YES];
    
}

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
- (void)viewWillAppear:(BOOL)animated{
    self.tabBarController.tabBar.hidden = NO;
}
@end
